package com.module.home.ui.home.provider

import android.view.View
import android.view.View.OnClickListener
import android.widget.TextView
import com.chad.library.adapter.base.provider.BaseItemProvider
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.common.app.data.bean.KeyEvents
import com.common.app.data.bean.home.HomeMainCardModel
import com.common.base.app.extras.setOnClickListener
import com.jeremyliao.liveeventbus.LiveEventBus
import com.module.home.R


/**
 *
 * 作者：sosou
 *
 * 版本：1.0
 *
 * 创建日期：2025/06/25
 *
 * 描述：
 *
 * 修订历史：
 *
 */
class SceneModeSelectProvider(override val itemViewType: Int = 10086,
                               override val layoutId: Int = R.layout.home_provider_scene_mode_item,
) : BaseItemProvider<HomeMainCardModel>(),OnClickListener {


    override fun convert(helper: BaseViewHolder, item: HomeMainCardModel) {
        helper.getView<TextView>(R.id.tvMorningMode).setOnClickListener(onClick = this)
        helper.getView<TextView>(R.id.tvNoonMode).setOnClickListener(onClick = this)
        helper.getView<TextView>(R.id.tvAfternoonMode).setOnClickListener(onClick = this)
    }

    override fun onClick(v: View?) {
        when (v?.id) {
            R.id.tvMorningMode -> LiveEventBus.get(KeyEvents.KEY_HOME_SCENE_MODE_CONFIG).post(1)
            R.id.tvNoonMode -> LiveEventBus.get(KeyEvents.KEY_HOME_SCENE_MODE_CONFIG).post(2)
            R.id.tvAfternoonMode -> LiveEventBus.get(KeyEvents.KEY_HOME_SCENE_MODE_CONFIG).post(3)
            else -> {
            }
        }
    }
}